using System;

namespace NVelocity.Test {

    public class TestSupportClass {
	public static long FileLength(System.IO.FileInfo file) {
	    if (System.IO.Directory.Exists(file.FullName))
		return 0;
	    else 
		return file.Length;
	}

	/*******************************/
	public static System.Int32 ReadInput(System.IO.Stream sourceStream, ref sbyte[] target, int start, int count) {
	    byte[] receiver = new byte[target.Length];
	    int bytesRead   = sourceStream.Read(receiver, start, count);
			
	    for(int i = start; i < start + bytesRead; i++)
		target[i] = (sbyte)receiver[i];
			
	    return bytesRead;
	}

	/*******************************/
	public static void WriteStackTrace(System.Exception throwable, System.IO.TextWriter stream) {
	    stream.Write(throwable.StackTrace);
	    stream.Flush();
	}

	/*******************************/
	public static System.Object PutElement(System.Collections.Hashtable hashTable, System.Object key, System.Object newValue) {
	    System.Object element = hashTable[key];
	    hashTable[key] = newValue;
	    return element;
	}

    }
}